package org.japo.java.jdbc.samples;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;
import javax.swing.JSlider;
import org.japo.java.entities.Modulo;

public class NavegadorModulosDual extends javax.swing.JFrame {

    // Nombre de la base de datos
    private final String BD = "Agenda";

    // SGBD soportador - Selección del SGBD activo
    private final String PRODUCTO1 = "Access";   // Access
    private final String PRODUCTO2 = "MySQL";    // MySQL
    private final String PRODUCTO_ACTIVO = PRODUCTO2;

    // Referencias para la gestión de la base de datos
    private Connection con = null;
    private Statement stmtA = null;
    private Statement stmtB = null;
    private ResultSet rsA = null;
    private ResultSet rsB = null;

    // Referencia a los modelos de enlace con el interfaz
    private Modulo moduloA;
    private Modulo moduloB;

    public NavegadorModulosDual() {
        iniciarAnterior();
        initComponents();
        iniciarPosterior();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        btgCurso = new javax.swing.ButtonGroup();
        pnlDatosA = new javax.swing.JPanel();
        lblIdA = new javax.swing.JLabel();
        lblAcronimoA = new javax.swing.JLabel();
        lblNombreA = new javax.swing.JLabel();
        lblCodigoA = new javax.swing.JLabel();
        lblHorasA = new javax.swing.JLabel();
        LblCursoA = new javax.swing.JLabel();
        lblHorasDatoA = new javax.swing.JLabel();
        txfIdA = new javax.swing.JTextField();
        txfAcronimoA = new javax.swing.JTextField();
        txfNombreA = new javax.swing.JTextField();
        txfCodigoA = new javax.swing.JTextField();
        rbtCurso1A = new javax.swing.JRadioButton();
        rbtCurso2A = new javax.swing.JRadioButton();
        sldHorasA = new javax.swing.JSlider();
        pnlControlA = new javax.swing.JPanel();
        btnIniA = new javax.swing.JButton();
        btnAntA = new javax.swing.JButton();
        btnSigA = new javax.swing.JButton();
        btnFinA = new javax.swing.JButton();
        sldRegActA = new javax.swing.JSlider();
        lblRegActA = new javax.swing.JLabel();
        lblNumRegA = new javax.swing.JLabel();
        pnlDatosB = new javax.swing.JPanel();
        lblIdB = new javax.swing.JLabel();
        lblAcronimoB = new javax.swing.JLabel();
        lblNombreB = new javax.swing.JLabel();
        lblCodigoB = new javax.swing.JLabel();
        lblHorasB = new javax.swing.JLabel();
        LblCursoB = new javax.swing.JLabel();
        txfIdB = new javax.swing.JTextField();
        txfAcronimoB = new javax.swing.JTextField();
        txfNombreB = new javax.swing.JTextField();
        txfCodigoB = new javax.swing.JTextField();
        lblHorasDatoB = new javax.swing.JLabel();
        rbtCurso1B = new javax.swing.JRadioButton();
        rbtCurso2B = new javax.swing.JRadioButton();
        sldHorasB = new javax.swing.JSlider();
        pnlControlB = new javax.swing.JPanel();
        btnIniB = new javax.swing.JButton();
        btnAntB = new javax.swing.JButton();
        btnSigB = new javax.swing.JButton();
        btnFinB = new javax.swing.JButton();
        sldRegActB = new javax.swing.JSlider();
        lblRegActB = new javax.swing.JLabel();
        lblNumRegB = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Navegador de módulos");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        pnlDatosA.setBorder(javax.swing.BorderFactory.createTitledBorder("Panel de datos A"));

        lblIdA.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblIdA.setText("Id");

        lblAcronimoA.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblAcronimoA.setText("Acrónimo");

        lblNombreA.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblNombreA.setText("Nombre");

        lblCodigoA.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblCodigoA.setText("Código");

        lblHorasA.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblHorasA.setText("Horas");

        LblCursoA.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        LblCursoA.setText("Curso");

        lblHorasDatoA.setBackground(new java.awt.Color(255, 255, 255));
        lblHorasDatoA.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblHorasDatoA.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblHorasDatoA.setOpaque(true);

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, sldHorasA, org.jdesktop.beansbinding.ELProperty.create("${value}"), lblHorasDatoA, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        txfIdA.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloA.id}"), txfIdA, org.jdesktop.beansbinding.BeanProperty.create("text_ON_FOCUS_LOST"), "id");
        bindingGroup.addBinding(binding);

        txfAcronimoA.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloA.acronimo}"), txfAcronimoA, org.jdesktop.beansbinding.BeanProperty.create("text_ON_FOCUS_LOST"), "acronimo");
        bindingGroup.addBinding(binding);

        txfNombreA.setAutoscrolls(false);
        txfNombreA.setEnabled(false);
        txfNombreA.setMaximumSize(new java.awt.Dimension(6, 20));
        txfNombreA.setPreferredSize(new java.awt.Dimension(20, 20));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloA.nombre}"), txfNombreA, org.jdesktop.beansbinding.BeanProperty.create("text_ON_FOCUS_LOST"), "nombre");
        bindingGroup.addBinding(binding);

        txfCodigoA.setAutoscrolls(false);
        txfCodigoA.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloA.codigo}"), txfCodigoA, org.jdesktop.beansbinding.BeanProperty.create("text_ON_FOCUS_LOST"), "");
        bindingGroup.addBinding(binding);

        btgCurso.add(rbtCurso1A);
        rbtCurso1A.setText("Primero");
        rbtCurso1A.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloA.curso1}"), rbtCurso1A, org.jdesktop.beansbinding.BeanProperty.create("selected"));
        bindingGroup.addBinding(binding);

        btgCurso.add(rbtCurso2A);
        rbtCurso2A.setText("Segundo");
        rbtCurso2A.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloA.curso2}"), rbtCurso2A, org.jdesktop.beansbinding.BeanProperty.create("selected"));
        bindingGroup.addBinding(binding);

        sldHorasA.setMajorTickSpacing(50);
        sldHorasA.setMaximum(500);
        sldHorasA.setPaintLabels(true);
        sldHorasA.setPaintTicks(true);
        sldHorasA.setToolTipText("");
        sldHorasA.setValue(0);
        sldHorasA.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloA.horas}"), sldHorasA, org.jdesktop.beansbinding.BeanProperty.create("value"));
        bindingGroup.addBinding(binding);

        javax.swing.GroupLayout pnlDatosALayout = new javax.swing.GroupLayout(pnlDatosA);
        pnlDatosA.setLayout(pnlDatosALayout);
        pnlDatosALayout.setHorizontalGroup(
            pnlDatosALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosALayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatosALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDatosALayout.createSequentialGroup()
                        .addComponent(lblHorasA)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sldHorasA, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblHorasDatoA, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlDatosALayout.createSequentialGroup()
                        .addGroup(pnlDatosALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlDatosALayout.createSequentialGroup()
                                .addComponent(lblAcronimoA)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txfAcronimoA, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlDatosALayout.createSequentialGroup()
                                .addComponent(lblIdA, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txfIdA, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlDatosALayout.createSequentialGroup()
                                .addComponent(lblNombreA)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txfNombreA, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlDatosALayout.createSequentialGroup()
                                .addComponent(lblCodigoA)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txfCodigoA, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(pnlDatosALayout.createSequentialGroup()
                .addComponent(LblCursoA, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rbtCurso1A)
                .addGap(18, 18, 18)
                .addComponent(rbtCurso2A)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pnlDatosALayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {lblAcronimoA, lblCodigoA, lblHorasA, lblIdA, lblNombreA});

        pnlDatosALayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {txfAcronimoA, txfCodigoA, txfIdA, txfNombreA});

        pnlDatosALayout.setVerticalGroup(
            pnlDatosALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosALayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatosALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txfIdA, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblIdA))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txfAcronimoA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblAcronimoA))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNombreA)
                    .addComponent(txfNombreA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCodigoA)
                    .addComponent(txfCodigoA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblHorasA)
                    .addComponent(sldHorasA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblHorasDatoA, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LblCursoA)
                    .addComponent(rbtCurso1A, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rbtCurso2A, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlDatosALayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {LblCursoA, lblAcronimoA, lblCodigoA, lblHorasA, lblHorasDatoA, lblIdA, lblNombreA, rbtCurso1A, rbtCurso2A, txfAcronimoA, txfCodigoA, txfIdA, txfNombreA});

        pnlControlA.setBorder(javax.swing.BorderFactory.createTitledBorder("Panel de control A"));

        btnIniA.setText("<<");
        btnIniA.setEnabled(false);
        btnIniA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIniAActionPerformed(evt);
            }
        });

        btnAntA.setText("<");
        btnAntA.setEnabled(false);
        btnAntA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAntAActionPerformed(evt);
            }
        });

        btnSigA.setText(">");
        btnSigA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSigAActionPerformed(evt);
            }
        });

        btnFinA.setText(">>");
        btnFinA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFinAActionPerformed(evt);
            }
        });

        sldRegActA.setBackground(new java.awt.Color(51, 153, 255));
        sldRegActA.setMaximum(0);
        sldRegActA.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                sldRegActAStateChanged(evt);
            }
        });

        lblRegActA.setBackground(new java.awt.Color(255, 255, 255));
        lblRegActA.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblRegActA.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblRegActA.setOpaque(true);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, sldRegActA, org.jdesktop.beansbinding.ELProperty.create("${value}"), lblRegActA, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        lblNumRegA.setBackground(new java.awt.Color(255, 255, 255));
        lblNumRegA.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblNumRegA.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblNumRegA.setOpaque(true);

        javax.swing.GroupLayout pnlControlALayout = new javax.swing.GroupLayout(pnlControlA);
        pnlControlA.setLayout(pnlControlALayout);
        pnlControlALayout.setHorizontalGroup(
            pnlControlALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlControlALayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlControlALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlControlALayout.createSequentialGroup()
                        .addComponent(btnIniA)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnAntA)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnSigA)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnFinA, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlControlALayout.createSequentialGroup()
                        .addComponent(sldRegActA, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblRegActA, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblNumRegA, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        pnlControlALayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnAntA, btnFinA, btnIniA, btnSigA});

        pnlControlALayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {lblNumRegA, lblRegActA});

        pnlControlALayout.setVerticalGroup(
            pnlControlALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlControlALayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlControlALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnIniA)
                    .addComponent(btnAntA)
                    .addComponent(btnFinA)
                    .addComponent(btnSigA))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlControlALayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sldRegActA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblRegActA, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNumRegA, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlControlALayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {lblNumRegA, lblRegActA, sldRegActA});

        pnlDatosB.setBorder(javax.swing.BorderFactory.createTitledBorder("Panel de datos B"));

        lblIdB.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblIdB.setText("Id");

        lblAcronimoB.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblAcronimoB.setText("Acrónimo");

        lblNombreB.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblNombreB.setText("Nombre");

        lblCodigoB.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblCodigoB.setText("Código");

        lblHorasB.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblHorasB.setText("Horas");

        LblCursoB.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        LblCursoB.setText("Curso");

        txfIdB.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloB.id}"), txfIdB, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        txfAcronimoB.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloB.acronimo}"), txfAcronimoB, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        txfNombreB.setAutoscrolls(false);
        txfNombreB.setEnabled(false);
        txfNombreB.setMaximumSize(new java.awt.Dimension(6, 20));
        txfNombreB.setPreferredSize(new java.awt.Dimension(20, 20));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloB.nombre}"), txfNombreB, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        txfCodigoB.setAutoscrolls(false);
        txfCodigoB.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloB.codigo}"), txfCodigoB, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        lblHorasDatoB.setBackground(new java.awt.Color(255, 255, 255));
        lblHorasDatoB.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblHorasDatoB.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblHorasDatoB.setOpaque(true);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, sldHorasB, org.jdesktop.beansbinding.ELProperty.create("${value}"), lblHorasDatoB, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        btgCurso.add(rbtCurso1B);
        rbtCurso1B.setText("Primero");
        rbtCurso1B.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloB.curso1}"), rbtCurso1B, org.jdesktop.beansbinding.BeanProperty.create("selected"));
        bindingGroup.addBinding(binding);

        btgCurso.add(rbtCurso2B);
        rbtCurso2B.setText("Segundo");
        rbtCurso2B.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloB.curso2}"), rbtCurso2B, org.jdesktop.beansbinding.BeanProperty.create("selected"));
        bindingGroup.addBinding(binding);

        sldHorasB.setMajorTickSpacing(50);
        sldHorasB.setMaximum(500);
        sldHorasB.setPaintLabels(true);
        sldHorasB.setPaintTicks(true);
        sldHorasB.setToolTipText("");
        sldHorasB.setValue(0);
        sldHorasB.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${moduloB.horas}"), sldHorasB, org.jdesktop.beansbinding.BeanProperty.create("value"));
        bindingGroup.addBinding(binding);

        javax.swing.GroupLayout pnlDatosBLayout = new javax.swing.GroupLayout(pnlDatosB);
        pnlDatosB.setLayout(pnlDatosBLayout);
        pnlDatosBLayout.setHorizontalGroup(
            pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosBLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDatosBLayout.createSequentialGroup()
                        .addGroup(pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlDatosBLayout.createSequentialGroup()
                                .addComponent(lblAcronimoB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txfAcronimoB, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlDatosBLayout.createSequentialGroup()
                                .addComponent(lblIdB, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txfIdB, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlDatosBLayout.createSequentialGroup()
                                .addComponent(lblNombreB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txfNombreB, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlDatosBLayout.createSequentialGroup()
                                .addComponent(lblCodigoB)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txfCodigoB, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(pnlDatosBLayout.createSequentialGroup()
                        .addGroup(pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(LblCursoB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lblHorasB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlDatosBLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(sldHorasB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblHorasDatoB, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlDatosBLayout.createSequentialGroup()
                                .addGap(13, 13, 13)
                                .addComponent(rbtCurso1B)
                                .addGap(18, 18, 18)
                                .addComponent(rbtCurso2B)
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addContainerGap())
        );

        pnlDatosBLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {lblAcronimoB, lblCodigoB, lblHorasB, lblIdB, lblNombreB});

        pnlDatosBLayout.setVerticalGroup(
            pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosBLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txfIdB, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblIdB))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txfAcronimoB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblAcronimoB))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblNombreB)
                    .addComponent(txfNombreB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCodigoB)
                    .addComponent(txfCodigoB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblHorasB)
                    .addComponent(sldHorasB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblHorasDatoB, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LblCursoB)
                    .addComponent(rbtCurso1B, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(rbtCurso2B, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlDatosBLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {LblCursoB, lblAcronimoB, lblCodigoB, lblHorasB, lblHorasDatoB, lblIdB, lblNombreB, rbtCurso1B, rbtCurso2B, txfAcronimoB, txfCodigoB, txfIdB, txfNombreB});

        pnlControlB.setBorder(javax.swing.BorderFactory.createTitledBorder("Panel de control B"));

        btnIniB.setText("<<");
        btnIniB.setEnabled(false);
        btnIniB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIniBActionPerformed(evt);
            }
        });

        btnAntB.setText("<");
        btnAntB.setEnabled(false);
        btnAntB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAntBActionPerformed(evt);
            }
        });

        btnSigB.setText(">");
        btnSigB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSigBActionPerformed(evt);
            }
        });

        btnFinB.setText(">>");
        btnFinB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFinBActionPerformed(evt);
            }
        });

        sldRegActB.setBackground(new java.awt.Color(51, 153, 255));
        sldRegActB.setMaximum(0);
        sldRegActB.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                sldRegActBStateChanged(evt);
            }
        });

        lblRegActB.setBackground(new java.awt.Color(255, 255, 255));
        lblRegActB.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblRegActB.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblRegActB.setOpaque(true);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, sldRegActB, org.jdesktop.beansbinding.ELProperty.create("${value}"), lblRegActB, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        lblNumRegB.setBackground(new java.awt.Color(255, 255, 255));
        lblNumRegB.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblNumRegB.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        lblNumRegB.setOpaque(true);

        javax.swing.GroupLayout pnlControlBLayout = new javax.swing.GroupLayout(pnlControlB);
        pnlControlB.setLayout(pnlControlBLayout);
        pnlControlBLayout.setHorizontalGroup(
            pnlControlBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlControlBLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlControlBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlControlBLayout.createSequentialGroup()
                        .addComponent(btnIniB)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnAntB)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnSigB)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnFinB, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlControlBLayout.createSequentialGroup()
                        .addComponent(sldRegActB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblRegActB, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblNumRegB, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        pnlControlBLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnAntB, btnFinB, btnIniB, btnSigB});

        pnlControlBLayout.setVerticalGroup(
            pnlControlBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlControlBLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlControlBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnIniB)
                    .addComponent(btnAntB)
                    .addComponent(btnFinB)
                    .addComponent(btnSigB))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlControlBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sldRegActB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblRegActB, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNumRegB, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlControlBLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {lblNumRegB, lblRegActB, sldRegActB});

        pnlControlBLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btnAntB, btnFinB, btnIniB, btnSigB});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(pnlDatosA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlControlA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlDatosB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlControlB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlDatosA, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlDatosB, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlControlB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pnlControlA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        bindingGroup.bind();

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void btnAntAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAntAActionPerformed
        try {
            if (rsA.previous()) {
                actualizarInterfazA();
            }
        } catch (SQLException sqle) {
            System.out.println("Sig: " + sqle);
        }
    }//GEN-LAST:event_btnAntAActionPerformed

    private void btnSigAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSigAActionPerformed
        try {
            if (rsA.next()) {
                actualizarInterfazA();
            }
        } catch (SQLException sqle) {
            System.out.println("Sig: " + sqle);
        }
    }//GEN-LAST:event_btnSigAActionPerformed

    private void btnIniAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIniAActionPerformed
        try {
            if (rsA.first()) {
                actualizarInterfazA();
            }
        } catch (SQLException sqle) {
            System.out.println("Ini: " + sqle);
        }
    }//GEN-LAST:event_btnIniAActionPerformed

    private void btnFinAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFinAActionPerformed
        try {
            if (rsA.last()) {
                actualizarInterfazA();
            }
        } catch (SQLException sqle) {
            System.out.println("Fin: " + sqle);
        }
    }//GEN-LAST:event_btnFinAActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        cerrarBD();
    }//GEN-LAST:event_formWindowClosing

    private void sldRegActAStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sldRegActAStateChanged
        try {
            if (rsA.absolute(sldRegActA.getValue())) {
                actualizarInterfazA();
            }
        } catch (SQLException sqle) {
            System.out.println("Sig: " + sqle);
        }
    }//GEN-LAST:event_sldRegActAStateChanged

    private void btnIniBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIniBActionPerformed
        try {
            if (rsB.first()) {
                actualizarInterfazB();
            }
        } catch (SQLException sqle) {
            System.out.println("Ini: " + sqle);
        }
    }//GEN-LAST:event_btnIniBActionPerformed

    private void btnAntBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAntBActionPerformed
        try {
            if (rsB.previous()) {
                actualizarInterfazB();
            }
        } catch (SQLException sqle) {
            System.out.println("Sig: " + sqle);
        }
    }//GEN-LAST:event_btnAntBActionPerformed

    private void btnSigBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSigBActionPerformed
        try {
            if (rsB.next()) {
                actualizarInterfazB();
            }
        } catch (SQLException sqle) {
            System.out.println("Sig: " + sqle);
        }
    }//GEN-LAST:event_btnSigBActionPerformed

    private void btnFinBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFinBActionPerformed
        try {
            if (rsB.last()) {
                actualizarInterfazB();
            }
        } catch (SQLException sqle) {
            System.out.println("Fin: " + sqle);
        }
    }//GEN-LAST:event_btnFinBActionPerformed

    private void sldRegActBStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sldRegActBStateChanged
        try {
            if (rsB.absolute(sldRegActB.getValue())) {
                actualizarInterfazB();
            }
        } catch (SQLException sqle) {
            System.out.println("Sig: " + sqle);
        }
    }//GEN-LAST:event_sldRegActBStateChanged

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NavegadorModulosDual.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NavegadorModulosDual.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NavegadorModulosDual.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NavegadorModulosDual.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new NavegadorModulosDual().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel LblCursoA;
    private javax.swing.JLabel LblCursoB;
    private javax.swing.ButtonGroup btgCurso;
    private javax.swing.JButton btnAntA;
    private javax.swing.JButton btnAntB;
    private javax.swing.JButton btnFinA;
    private javax.swing.JButton btnFinB;
    private javax.swing.JButton btnIniA;
    private javax.swing.JButton btnIniB;
    private javax.swing.JButton btnSigA;
    private javax.swing.JButton btnSigB;
    private javax.swing.JLabel lblAcronimoA;
    private javax.swing.JLabel lblAcronimoB;
    private javax.swing.JLabel lblCodigoA;
    private javax.swing.JLabel lblCodigoB;
    private javax.swing.JLabel lblHorasA;
    private javax.swing.JLabel lblHorasB;
    private javax.swing.JLabel lblHorasDatoA;
    private javax.swing.JLabel lblHorasDatoB;
    private javax.swing.JLabel lblIdA;
    private javax.swing.JLabel lblIdB;
    private javax.swing.JLabel lblNombreA;
    private javax.swing.JLabel lblNombreB;
    private javax.swing.JLabel lblNumRegA;
    private javax.swing.JLabel lblNumRegB;
    private javax.swing.JLabel lblRegActA;
    private javax.swing.JLabel lblRegActB;
    private javax.swing.JPanel pnlControlA;
    private javax.swing.JPanel pnlControlB;
    private javax.swing.JPanel pnlDatosA;
    private javax.swing.JPanel pnlDatosB;
    private javax.swing.JRadioButton rbtCurso1A;
    private javax.swing.JRadioButton rbtCurso1B;
    private javax.swing.JRadioButton rbtCurso2A;
    private javax.swing.JRadioButton rbtCurso2B;
    private javax.swing.JSlider sldHorasA;
    private javax.swing.JSlider sldHorasB;
    private javax.swing.JSlider sldRegActA;
    private javax.swing.JSlider sldRegActB;
    private javax.swing.JTextField txfAcronimoA;
    private javax.swing.JTextField txfAcronimoB;
    private javax.swing.JTextField txfCodigoA;
    private javax.swing.JTextField txfCodigoB;
    private javax.swing.JTextField txfIdA;
    private javax.swing.JTextField txfIdB;
    private javax.swing.JTextField txfNombreA;
    private javax.swing.JTextField txfNombreB;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    private void conectarAccess() throws Exception {
        // Protocolo del driver
        final String PROTOCOLO_ACCESS = "jdbc:odbc";

        // Cadena de conexión de Access
        final String CADENA_ACCESS = PROTOCOLO_ACCESS + ":" + BD;

        // Realiza la conexión
        System.out.println("Abriendo " + BD + " ...");
        con = DriverManager.getConnection(CADENA_ACCESS);
        System.out.println("Base de datos " + BD + " conectada.");
    }

    private void conectarMySQL() throws Exception {
        // Protocolo del driver
        final String PROTOCOLO_MySQL = "jdbc:mysql";

        // Servidor
        final String SERVIDOR = "localhost";
        final int PUERTO = 3306;

        // Usuario
        final String USUARIO = "usuario";
        final String PASSWORD = "usuario";

        // Cadena de conexión de MySQL
        final String CADENA_MySQL = ""
                + PROTOCOLO_MySQL + "://"
                + SERVIDOR + ":"
                + PUERTO + "/"
                + BD;

        // Realiza la conexión
        System.out.println("Abriendo " + BD + " ...");
        con = DriverManager.getConnection(CADENA_MySQL, USUARIO, PASSWORD);
        System.out.println("Base de datos " + BD + " conectada.");
    }

    private void iniciarAnterior() {
        // Instanciar el modelo A de datos
        moduloA = new Modulo();

        // Instanciar el modelo B de datos
        moduloB = new Modulo();

        // Crear el acceso a la base de datos
        crearAccesoDatos();
    }

    private void iniciarPosterior() {
        actualizarInterfazA();
        actualizarInterfazB();
    }

    private void crearAccesoDatos() {
        try {
            conectarBD();
        } catch (Exception e) {
            // Información de depuración
            Logger.getLogger(NavegadorModulosDual.class.getName()).log(Level.SEVERE, null, e);

            // Cierra la base de datos
            cerrarBD();

            // Finaliza el programa
            terminarPrograma();
        }
    }

    private void conectarBD() throws Exception {
        // Conecta con la base de datos
        if (PRODUCTO_ACTIVO.equals(PRODUCTO1)) {
            conectarAccess();
        } else if (PRODUCTO_ACTIVO.equals(PRODUCTO2)) {
            conectarMySQL();
        } else {
            throw new Exception("No se ha seleccionado producto");
        }

        // ---- CAMBIOS DE DATOS ----
        // ResultSet.TYPE_FORWARD_ONLY (*) - Indica que el objeto ResultSet se 
        //      puede recorrer unicamente hacia adelante.
        // ResultSet.TYPE_SCROLL_INSENSITIVE - Indica que el objeto ResultSet se 
        //      puede recorrer, pero en general no es sensible a los cambios en 
        //      los datos que subyacen en él.
        // ResultSet.TYPE_SCROLL_SENSITIVE - Indica que el objeto ResultSet se 
        //      puede recorrer, y además, los cambios en él repercuten
        //      en la base de datos subyacente.
        // ---- MODOS DE CONCURRENCIA ----
        // ResultSet.CONCUR_READ_ONLY (*) - Indica que en el modo de concurrencia 
        //      para el objeto ResultSet éste no puede ser actualizado.
        // ResultSet.CONCUR_UPDATABLE - Indica que en el modo de concurrencia 
        //      para el objeto ResultSet éste podria ser actualizado.
        //
        // Crear una sentencia
        stmtA = con.createStatement(
                ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        stmtB = con.createStatement(
                ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);

        // Sentencia SQL para la consulta
        final String SQL = "SELECT * FROM Modulo";

        // Obtener los resultados de las consultas
        rsA = stmtA.executeQuery(SQL);
        rsB = stmtB.executeQuery(SQL);
    }

    private void actualizarInterfazA() {
        try {
            // Actualizar datos interfaz
            importarModelo(moduloA, rsA);

            // Actualizar botones
            actualizarNavegadorA();

            // Actualizar selector
            actualizarSelector(sldRegActA, lblNumRegA, rsA);
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    private void actualizarInterfazB() {
        try {
            // Actualizar datos interfaz
            importarModelo(moduloB, rsB);

            // Actualizar botones
            actualizarNavegadorB();

            // Actualizar selector
            actualizarSelector(sldRegActB, lblNumRegB, rsB);
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    private void importarModelo(Modulo m, ResultSet rs) throws Exception {
        // Obtener el número de filas
        int totFilas = calcularNumeroRegistros(rs);

        if (totFilas > 0) {
            // Importa los datos de la fila actual
            m.setId(rs.getInt(1) + "");
            m.setAcronimo(rs.getString(2));
            m.setNombre(rs.getString(3));
            m.setCodigo(rs.getString(4));
            m.setHoras(rs.getInt(5));
            m.setCurso1(rs.getInt(6) == 1);
            m.setCurso2(rs.getInt(6) == 2);
        } else {
            // Datos arbitrarios cuando no hay filas
            m.setId("");
            m.setAcronimo("");
            m.setNombre("");
            m.setCodigo("");
            m.setHoras(0);
            m.setCurso1(false);
            m.setCurso2(false);
        }
    }

    private void actualizarNavegadorA() throws Exception {
        // Obtener el número de filas
        int totFilas = calcularNumeroRegistros(rsA);

        // Obtener la fila actual
        int filaAct = rsA.getRow();

        if (totFilas == 0) {                        // Base de datos vacia
            btnAntA.setEnabled(false);
            btnIniA.setEnabled(false);
            btnSigA.setEnabled(false);
            btnFinA.setEnabled(false);
        } else if (totFilas == 1) {                 // Un sólo registro
            btnAntA.setEnabled(false);
            btnIniA.setEnabled(false);
            btnSigA.setEnabled(false);
            btnFinA.setEnabled(false);
        } else if (filaAct == 1) {                  // Primer registro
            btnAntA.setEnabled(false);
            btnIniA.setEnabled(false);
            btnSigA.setEnabled(true);
            btnFinA.setEnabled(true);
        } else if (filaAct == totFilas) {           // Último registro
            btnAntA.setEnabled(true);
            btnIniA.setEnabled(true);
            btnSigA.setEnabled(false);
            btnFinA.setEnabled(false);
        } else {                                    // Registro intermedio
            btnAntA.setEnabled(true);
            btnIniA.setEnabled(true);
            btnSigA.setEnabled(true);
            btnFinA.setEnabled(true);
        }
    }

    private void actualizarNavegadorB() throws Exception {
        // Obtener el número de filas
        int totFilas = calcularNumeroRegistros(rsB);

        // Obtener la fila actual
        int filaAct = rsB.getRow();

        if (totFilas == 0) {                        // Base de datos vacia
            btnAntB.setEnabled(false);
            btnIniB.setEnabled(false);
            btnSigB.setEnabled(false);
            btnFinB.setEnabled(false);
        } else if (totFilas == 1) {                 // Un sólo registro
            btnAntB.setEnabled(false);
            btnIniB.setEnabled(false);
            btnSigB.setEnabled(false);
            btnFinB.setEnabled(false);
        } else if (filaAct == 1) {                  // Primer registro
            btnAntB.setEnabled(false);
            btnIniB.setEnabled(false);
            btnSigB.setEnabled(true);
            btnFinB.setEnabled(true);
        } else if (filaAct == totFilas) {           // Último registro
            btnAntB.setEnabled(true);
            btnIniB.setEnabled(true);
            btnSigB.setEnabled(false);
            btnFinB.setEnabled(false);
        } else {                                    // Registro intermedio
            btnAntB.setEnabled(true);
            btnIniB.setEnabled(true);
            btnSigB.setEnabled(true);
            btnFinB.setEnabled(true);
        }
    }

    private void actualizarSelector(JSlider sldActual, JLabel lblActual,
            ResultSet rs) throws Exception {

        // Obtener el número de filas
        int totFilas = calcularNumeroRegistros(rs);

        // Obtener la fila actual
        int filaAct = rs.getRow();

        // Analiza el estado del deslizador
        if (totFilas > 0) {
            // Deslizador
            sldActual.setEnabled(true);
            sldActual.setMinimum(1);          // Change Listeners notificados
            sldActual.setMaximum(totFilas);   // Change Listeners notificados
            sldActual.setValue(filaAct);      // Change Listeners notificados

            // Total de registros
            lblActual.setText(totFilas + "");
        } else {
            // Deslizador
            sldActual.setEnabled(false);
            sldActual.setMinimum(0);          // Change Listeners notificados
            sldActual.setMaximum(0);          // Change Listeners notificados
            sldActual.setValue(0);            // Change Listeners notificados

            // Total de registros
            lblActual.setText("0");
        }
    }

    public Modulo getModuloA() {
        return moduloA;
    }

    public void setModuloA(Modulo modulo) {
        this.moduloA = modulo;
    }

    public Modulo getModuloB() {
        return moduloB;
    }

    public void setModuloB(Modulo modulo) {
        this.moduloB = modulo;
    }

    private void cerrarBD() {
        // Mensaje
        System.out.println("Cerrando " + BD + " ...");

        // Cierra el ResultSet A
        try {
            rsA.close();
        } catch (SQLException | NullPointerException e) {
            Logger.getLogger(NavegadorModulosDual.class.getName()).log(Level.SEVERE, null, e);
        }

        // Cierra el ResultSet B
        try {
            rsB.close();
        } catch (SQLException | NullPointerException e) {
            Logger.getLogger(NavegadorModulosDual.class.getName()).log(Level.SEVERE, null, e);
        }

        // Cierra el Statement A
        try {
            stmtA.close();
        } catch (SQLException | NullPointerException e) {
            Logger.getLogger(NavegadorModulosDual.class.getName()).log(Level.SEVERE, null, e);
        }

        // Cierra el Statement B
        try {
            stmtB.close();
        } catch (SQLException | NullPointerException e) {
            Logger.getLogger(NavegadorModulosDual.class.getName()).log(Level.SEVERE, null, e);
        }

        // Cierra la conexión
        try {
            con.close();
        } catch (SQLException | NullPointerException e) {
            Logger.getLogger(NavegadorModulosDual.class.getName()).log(Level.SEVERE, null, e);
        }

        // Mensaje
        System.out.println("Base de datos " + BD + " cerrada.");
    }

    private void terminarPrograma() {
        setVisible(false);
        dispose();
        System.exit(0);
    }

    private int calcularNumeroRegistros(ResultSet rs) {
        // Variable para almacenar el resultado
        int numFilas;

        try {
            // Número de la fila a la que apunta el cursor
            int filaAct = rs.getRow();

            // Va al final del ResultSet
            rs.last();

            // Obtiene el número de filas
            numFilas = rs.getRow();

            if (filaAct != 0) {
                // Coloca el cursor en la posición previa
                rs.absolute(filaAct);
            } else {
                // Coloca el cursor al principio del ResultSet
                rs.first();
            }
        } catch (SQLException e) {
            numFilas = 0;
        }

        // Devuelve el número de filas calculadas
        return numFilas;
    }
}
